package shape2D;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.shape.*;
import javafx.scene.paint.Color;

// 椭圆   
public class EllipseDemo extends Application { 
	private Pane root = new Pane();
	private Ellipse ellipse;
	
	public static void main(String[] args) {
		Application.launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		root.setStyle("-fx-background-color: green");
		
		ellipse = new Ellipse();
		for(int i=0; i<16; i++) {
			ellipse = new Ellipse(100, 100, 100, 50);         // 中心坐标,水平半径,垂直半径
			ellipse.centerXProperty().bind(root.widthProperty().divide(2));   // 椭圆中心绑定
			ellipse.centerYProperty().bind(root.heightProperty().divide(2));
			ellipse.setFill(Color.WHITE);
			ellipse.setStroke(Color.color(Math.random(), Math.random(), Math.random()));
			ellipse.setRotate(i*180/16);             // 刚好旋转成圆的形状
			root.getChildren().add(ellipse);
		}
		
		Scene scene = new Scene(root, 300, 300);
		stage.setScene(scene);
		stage.show();
	}
}




